package com.example.test.责任连;

/**
 * @author hzj@jovision.com
 * @Date 2020/12/5 上午10:47
 * @Description 事件源逻辑职责链
 */
public class SourceHandlerChain {
    private AbstractSourceHandler head;
    private AbstractSourceHandler tail;

    public void addHandler(AbstractSourceHandler handler) {
        if (head == null) {
            head = handler;
            tail = handler;
            return;
        }

        tail.setNext(handler);
        tail = handler;
    }

    public void handle() {
        if (head != null) {
            head.handle();
        }
    }
}
